<?php


namespace app\test\controller;


use app\BaseController;
use app\service\serviceService;
use app\service\wotuService;
use think\facade\Db;

class Door extends BaseController
{
    public function yangzl2(){
        $url="https://www.zaozaopay.com/test/door/test";
        $id="23";
        $order=Db::table("zft_order_success")->where("uid",$id)->find();
        //echo "yangzl";
        $url=(new serviceService())->getNotifyUrlByComId($order["community_id"]);
        if(empty($url)){
            parent::sendOutput("回调地址不存在",500);
        }
        $con=$order["alipay_notify_con"];
        $jobQueueName  	  = "app\job\ZftNotifyUrl";
        $jobData       	  = [ 'id' =>$id ,"alipay_notify_con"=>$con,"community_id"=>$order["community_id"]] ;
        $res= \think\facade\Queue::push($jobQueueName,$jobData);
        var_dump($res);
    }
    public function yangzl(){
        $url="http://111.68.1.194:14332/api/pay/notifyurl";
        $url="http://111.68.1.194:14332/api/pay/sync/ymt/";
        $id="23";
        $order=Db::table("zft_order_success")->where("uid",$id)->find();
        //echo "yangzl";
        $con=$order["alipay_notify_con"];
        $res=$this->curl_post($url,$con,[]);
        var_dump($res);
    }

    public function test(){
        $path=dir(getcwd())->path.'/log/pay/zfttest2/'.date('Ymd');
        if (! file_exists ( $path )) {
            mkdir ( "$path", 0777, true );
        }
        $address = $path."/".date('His').rand(100000,999999).'yangzl.txt';
        file_put_contents($address,file_get_contents("php://input"),FILE_APPEND);
        parse_str(file_get_contents($address),$result);//读取文本并变成数组
        return "2";
        return "success";
        parent::sendOutput("2");
    }
    public function curl_post($url,$post_data,$header){
        $curl = curl_init();
        //设置抓取的url
        curl_setopt($curl, CURLOPT_URL, $url);
        //设置头文件的信息作为数据流输出
        //curl_setopt($curl, CURLOPT_HEADER, 1);
        //设置header域
        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        //设置获取的信息以文件流的形式返回，而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        //设置post方式提交
        curl_setopt($curl, CURLOPT_POST, 1);

        curl_setopt($curl, CURLOPT_POSTFIELDS,  $post_data);
        //执行命令
        $data = curl_exec($curl);
        //关闭URL请求
        curl_close($curl);
        return $data;//json_decode($data, true);
    }

}